<template>
    <el-container>
                <el-main>
        <StElDynamicForm :helper-form="helperForm" :submit-props="{method: 'get',loading: searchLoading,onSubmit:(form,data)=>{queryParams = $stObjectTools.clone(data)}}"
                         :options="OrderFormOptions" :origin-prop="{inline: true,labelWidth: '100px'}">
        </StElDynamicForm>
        <StElTable ref="steltable" :options="OrderTableOptions" @loading="(val)=>{searchLoading = val}" :datas="OrderUrl.searchList" :query-params="queryParams">
            <template #append>
                <el-table-column
                        label="操作"
                        width="200">
                    <template #default="{row,column,$index}">
                        <StElButtonGroup :group-param="{row,column,$index}" :operationMoreButtonOptions="{stype: 'link'}" :operations="tableOperations">
                        </StElButtonGroup>
                    </template>
                </el-table-column>

            </template>
        </StElTable>
        </el-main>
    </el-container>
</template>

<script>
    import OrderMixin from '../OrderMixin.js'
    import OrderGoodsUrl from '../OrderGoodsUrl.js'
    export default {
        name: "OrderSearchList",
        mixins: [OrderMixin],
        props: {
        },
        computed: {
        },
        data() {
            return {
                queryParams: {},
                searchLoading:  false,

                helperForm: {
                },

                tableOperations: [
                    {
                        label: '订单商品',
                        stype: 'link',
                        action: ({groupParam}) => {
                            this.$router.push({path: OrderGoodsUrl.router.searchList, query: {orderNo: groupParam.row.orderNo}})
                        }
                    },
                  {
                    label: '退款',
                    stype: 'link',
                    loading: false,
                    requestSuccess: ({groupParam}) => {
                      // 退款请求完成，重新加载数据
                      this.$refs.steltable.reloadData()
                    },
                    action: ({groupParam}) => {
                      return {
                        method: 'post',
                        url: OrderGoodsUrl.refund,
                        params: {orderNo: groupParam.row.orderNo,remark: '后台订单管理操作退款'},
                        confirmText: `确定要退款 ${groupParam.row.orderNo}吗？该退款操作会将订单全部款项返回给用户。`
                      }
                    }
                  },
                ]
            }
        },
        methods: {
        }
    }
</script>

<style scoped>

</style>